package com.dbiservices.dbiworker.ui;

import java.awt.Container;

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JPanel;

import com.dbiservices.dbiworker.ui.action.Action;


@SuppressWarnings("serial")
public class MainWindow extends Window{
	
	private JMenu fileMenu;

	public MainWindow() {
	}

	@Override
	public void initialize() {
		this.setTitle("DBI Worker");
		this.setSize(900, 400);
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		this.setJMenuBar(this.buildMenuBar());
		this.setContentPane(this.buildContentPane());
		this.setLocationRelativeTo(null);
		//this.pack();
		this.setVisible(true);
	}

	private Container buildContentPane() {
		JPanel panel = new JPanel();
		JLabel description = new JLabel("Welcome to DBI Worker. This is the default panel shown at startup.");
		panel.add(description);
		return panel;
	}

	private JMenuBar buildMenuBar() {
		JMenuBar bar = new JMenuBar();
		JMenu file = new JMenu("File");
		this.setFileMenu(file);
		JMenuItem quit = new JMenuItem(new Action("Quit", Action.A_QUIT));
		file.add(quit);
		bar.add(file);
		return bar;
	}
	
	public void refresh(){
		this.invalidate();
		this.validate();
	}

	@Override
	public String getWindowName() {
		return "DBI Worker";
	}

	public JMenu getFileMenu() {
		return this.fileMenu;
	}

	public void setFileMenu(JMenu fileMenu) {
		this.fileMenu = fileMenu;
	}
	
}
